#ifndef __BSP_AT24CXX_H__
#define __BSP_AT24CXX_H__


#include <stdint.h>
#include "stm32f4xx.h"

#define RCC_AT24CXX_PORT (RCC_AHB1Periph_GPIOA)		/* GPIO端口时钟 */

#define AT24CXX_SDA_PORT	GPIOA
#define AT24CXX_SDA_PIN	GPIO_Pin_11

#define AT24CXX_SCL_PORT	GPIOA
#define AT24CXX_SCL_PIN	GPIO_Pin_12

/* 设备地址 */
#define AT24CXX_I2C_ADDR 0xA0

#define AT24C02
// #define AT24C128

#ifdef AT24C02
	#define EE_MODEL_NAME		"AT24C02"
	#define EE_DEV_ADDR			0xA0		/* 设备地址 */
	#define EE_PAGE_SIZE		8			/* 页面大小(字节) */
	#define EE_SIZE				256			/* 总容量(字节) */
	#define EE_ADDR_BYTES		1			/* 地址字节个数 */
#endif

#ifdef AT24C128
	#define EE_MODEL_NAME		"AT24C128"
	#define EE_DEV_ADDR			0xA0		/* 设备地址 */
	#define EE_PAGE_SIZE		64			/* 页面大小(字节) */
	#define EE_SIZE				(16*1024)	/* 总容量(字节) */
	#define EE_ADDR_BYTES		2			/* 地址字节个数 */
#endif



void bsp_at24cxx_init(void);
uint8_t bsp_at24cxx_check(void);
uint8_t bsp_at24cxx_test(void);
uint8_t bsp_at24cxx_read_byte(uint32_t addr, uint8_t *data);
uint8_t bsp_at24cxx_write_byte(uint32_t addr, uint8_t data);
uint8_t bsp_at24cxx_read_bytes(uint32_t addr, uint8_t *data, uint16_t len);
uint8_t bsp_at24cxx_write_bytes(uint32_t addr, uint8_t *data, uint16_t len);



#endif
